home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 April: Mac OS SDK / Dev.CD Apr 98 SDK2.toast / Development Kits (Disc 2) / ScriptX / Documentation / Code Examples from Docs / compguid / collectn / lockarry.sx next >
Encoding:
Text File  |  1996-05-21  |  773 b   |  36 lines  |  [TEXT/ttxt]

  1. --<<<
  2.  
  3. -- ScriptX Architecture and Components Guide
  4. -- Collections Chapter
  5. -- LockedArray example
  6.  
  7. -- This example specializes just two Collection methods
  8. -- To create a robust LockedArray.  You should specialize all
  9. -- methods that add, remove, or change the order of items 
  10. -- in a Collection.
  11.  
  12. class LockedArray (Array)
  13.     inst vars lock
  14.     instance methods
  15.     method init self #rest args -> (
  16.         apply nextMethod self args
  17.         self.lock := new Lock
  18.     )
  19.     method acquire self -> acquire self.lock
  20.     method relinquish self -> relinquish self.lock
  21.     method add self key value -> (
  22.         acquire self
  23.         nextMethod self key value
  24.         relinquish self
  25.     )
  26.     method deleteOne self value -> (
  27.         acquire self
  28.         nextMethod self value
  29.         relinquish self
  30.     )
  31.     -- specialize other methods here
  32. end
  33.  
  34. -->>>
  35.  
  36.